#!/usr/bin/python

import os

from query.word_query import WordQuery
from util.csv import CSVFile
from util.frequency import FreqControl
from util.settings import DATA_DIR


# Load words and meanings from cvs file
wordFile = CSVFile(os.path.join(DATA_DIR, "2018-5500.csv"), 'utf8')
words = wordFile.read_dict(auto_close=True)

# Filter words
words = {word.lower(): meaning for word, meaning in words.items()}

# Frequency control with random sleep time
fc = FreqControl(thread_count=6, min_sleep_time=400, max_sleep_time=900)

# Query the above words with 6 thread
wq = WordQuery(words=words, freq_control=fc)
wq.query(query_all=True)
